package com.cxmx.escort.controller;


import com.cxmx.escort.base.BaseController;
import com.cxmx.escort.base.ResponseFormat;
import com.cxmx.escort.base.Result;
import com.cxmx.escort.entity.FeedBack;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 反馈信息 前端控制器
 * </p>
 *
 * @author 陈云轩
 * @since 2019-10-21
 */
@RestController
@RequestMapping("/feed-back")
@Validated
@Api(value = "反馈信息", tags = {"反馈接口"})
@SuppressWarnings("unchecked")
public class FeedBackController extends BaseController {
    @ApiOperation(value = "意见反馈", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "用户token", dataType = "String", paramType = "header", required = true),
    })
    @PostMapping
    public Result<Boolean> addFeedBack(@RequestBody FeedBack feedBack, @NotNull(message = "token不可为空") @RequestHeader("token") String token) {
        feedBack.setUserId(String.valueOf(getUserId(token)));
        feedBack.setAdoptFlag(0);
        return ResponseFormat.retParam(200, feedBackService.save(feedBack));
    }
}

